package com.token.sysflow.action;

import com.token.base.FuncUtil;
import com.token.base.Pl;
import com.token.sql.IntegrateSql;
import com.token.sysflow.impl.AbstractFlowHandlerImpl;
import com.token.sysflow.impl.LoadFlowStepImpl;

/**
 * 加载进入
 * @author chenjianxiong 2020/4/12
 */
public class LoadFlowStepAction extends AbstractFlowAction {
    @Override
    protected void publicParameter(FuncUtil f, AbstractFlowHandlerImpl handler) throws Exception {
        //操作时间
        handler.setActionTimer(Pl.getCurDataTime());

        //操作用户
        handler.setActionUser(f.getEffectiveUserName());

        //租户Id
        handler.setSysId(Pl.getSysId());
    }

    public void executeAction(FuncUtil f, IntegrateSql iSql) throws Exception{
        LoadFlowStepImpl handler = new LoadFlowStepImpl();
        String keyUnid = f.getUrlQueryString("keyUnid");

        //起草进入
        if(keyUnid == null || "".equals(keyUnid)) {
            handler.setLoadType(LoadFlowStepImpl.TYPE_FIRST);
            //应用KeyId
            handler.setAppKeyId(f.getUrlQueryString("appKeyId", true, "应用KeyId"));

            //申请人
            handler.setApplyer(f.getUrlQueryString("applyer", true, "申请人"));
        }else{
            //审批进入
            handler.setLoadType(LoadFlowStepImpl.TYPE_APPROVAL);
            handler.setKeyUnid(keyUnid);
        }

        this.start(f,iSql,handler);
    }
}
